<template>
  <el-pagination
    @size-change="onSizeChange"
    @current-change="onCurrentChange"
    :current-page="pagination.current"
    :page-size="pagination.size"
    :total="pagination.total"
    :pager-count="5"
    :page-sizes="[25, 50, 100, 150]"
    :layout="full?'prev, pager, next, jumper, sizes, total':'prev, pager, next'">
  </el-pagination>
</template>

<script>
export default {
  name: 'yc-pagination',
  props: {
    pagination: {
      type: Object,
      default: function () {
        return {
          current: 1,
          size: 25,
          total: 1
        }
      }
    },
    full: {
      type: Boolean,
      default: true
    }
  },
  methods: {
    onSizeChange (val) {
      this.pagination.size = val
      this.$emit('change', { currentPage: this.pagination.current, pageSize: this.pagination.size })
    },
    onCurrentChange (val) {
      this.pagination.current = val
      this.$emit('change', { currentPage: this.pagination.current, pageSize: this.pagination.size })
    }
  }
}
</script>
